package study;

public class TreadLocalDemo {

        // 定义两个不同的 ThreadLocal 变量
        private static ThreadLocal<String> nameLocal = new ThreadLocal<>();
        private static ThreadLocal<Integer> ageLocal = new ThreadLocal<>();

        public static void main(String[] args) {
            Thread thread1 = new Thread(() -> {
                nameLocal.set("Alice");
                ageLocal.set(25);
                System.out.println("Thread1: " + nameLocal.get() + ", " + ageLocal.get());
            });

            Thread thread2 = new Thread(() -> {
                nameLocal.set("Bob");
                ageLocal.set(30);
                System.out.println("Thread2: " + nameLocal.get() + ", " + ageLocal.get());
            });

            thread1.start();
            thread2.start();
        }

}
